package app

import (
	"chatgpt/helper/code"
	"chatgpt/logq"
	"chatgpt/plugin/rpcx"
	"chatgpt/services/datasrv/sqlhelper"
	"context"
)

func (self *OrderApi) RechargeSelect(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("OrderApi")
	err := client.Call(ctx, "RechargeSelect", req, res)
	if err != nil {
		logq.Error("DataSrv.Recharge.Select err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *OrderApi) RechargeSave(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("OrderApi")
	err := client.Call(ctx, "RechargeSave", req, res)
	if err != nil {
		logq.Error("DataSrv.Recharge.Save err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *OrderApi) RechargeTotal(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("OrderApi")
	err := client.Call(ctx, "RechargeTotal", req, res)
	if err != nil {
		logq.Error("DataSrv.Recharge.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *OrderApi) RechargeFirst(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("OrderApi")
	err := client.Call(ctx, "RechargeFirst", req, res)
	if err != nil {
		logq.Error("DataSrv.Recharge.Total err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}

func (self *OrderApi) RechargeDelete(ctx context.Context, req *sqlhelper.ReqWhere, res *sqlhelper.ResWhere) code.CODENO {
	client := rpcx.DataSrv.GetRand("OrderApi")
	err := client.Call(ctx, "RechargeDelete", req, res)
	if err != nil {
		logq.Error("DataSrv.Recharge.Delete err:", err)
		return code.DATA_CALL_ERROR
	}
	return res.MsgCode
}
